-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Earth - Ana #24
base: master
Are you sure you want to change the base?
Earth - Ana #24
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work Ana, you hit the main learning goals here. Well done. I did have some comments on space/time complexity. Please take a look and let me know what questions you have.
# Time Complexity: o(log(n)) | ||
# Space Complexity: o(1) | ||
def add(key, value = nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 the time complexity is O(log n) if the tree is balanced and O(n) if it's unbalanced. The space complexity is the same due to recursion.
# Time Complexity: o(n) | ||
# Space Complexity: o(n) | ||
def find(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 the time complexity is O(log n) if the tree is balanced and O(n) if it's unbalanced. The space complexity is the same due to recursion.
# Time Complexity: o(n) | ||
# Space Complexity: o(n) | ||
def inorder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# Time Complexity: o(n) | ||
# Space Complexity: o(n) | ||
def preorder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# Time Complexity: o(n) | ||
# Space Complexity: o(n) | ||
def postorder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# Time Complexity: o(n) | ||
# Space Complexity: o(n) | ||
def height |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 The space complexity is O(log n) if the tree is balanced and O(n) if it's unbalanced due to the recursion. You have the time complexity right.
No description provided.